import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:moose_app/core/mock/mock_follow_data.dart';
import 'package:moose_app/core/model/follow_item_model.dart';
import 'package:moose_app/ui/values/values.dart';

import 'follow_item.dart';

class ATHFollowContent extends StatefulWidget {
  @override
  _ATHFollowContentState createState() => _ATHFollowContentState();
}

class _ATHFollowContentState extends State<ATHFollowContent>
    with AutomaticKeepAliveClientMixin {
  // 总数

  @override
  Widget build(BuildContext context) {
    super.build(context);
    List<ATHFollowItemModel> followItemList = MockFollowItemData.followItemList;
    return EasyRefresh.custom(
        header: MaterialHeader(),
        footer: MaterialFooter(),
        onRefresh: () async {
          await Future.delayed(Duration(seconds: 2), () {
            if (mounted) {}
          });
        },
        onLoad: () async {
          await Future.delayed(Duration(seconds: 2), () {
            if (mounted) {}
          });
        },
        slivers: [
          SliverPadding(
            padding:
                EdgeInsets.symmetric(horizontal: kSize24, vertical: kSize20),
            sliver: SliverList(
              delegate: SliverChildBuilderDelegate(
                (context, index) {
                  ATHFollowItemModel followItem = followItemList[index];
                  return ATHFollowItem(
                    followItem: followItem,
                  );
                },
                childCount: followItemList.length,
              ),
            ),
          ),
        ]);
  }

  @override
  bool get wantKeepAlive => true;
}
